package plenprojects.guiclient.frames;

public class MessageViewFrame extends javax.swing.JFrame {
    
    private final String from;
    private final String topic;
    private final String message;
    
    public MessageViewFrame(String from, String topic, String message) {
        
        this.from = from;
        this.topic = topic;
        this.message = message;
        
        initComponents();
    }
    
    public void showWindow() {
        
        FromTextField.setText(from);
        TopicTextField.setText(topic);
        MessageTextArea.setText(message);
        
        this.setVisible(true);
    }
                       
    private void initComponents() {

        FromTextField = new javax.swing.JTextField();
        FromLabel = new javax.swing.JLabel();
        TopicTextField = new javax.swing.JTextField();
        TopicLabel = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        MessageTextArea = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Message view");
        setMinimumSize(new java.awt.Dimension(469, 330));
        setPreferredSize(new java.awt.Dimension(469, 330));

        FromTextField.setEditable(false);

        FromLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        FromLabel.setText("From: ");

        TopicTextField.setEditable(false);

        TopicLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        TopicLabel.setText("Topic:");

        MessageTextArea.setEditable(false);
        MessageTextArea.setColumns(20);
        MessageTextArea.setRows(5);
        jScrollPane1.setViewportView(MessageTextArea);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(FromLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(TopicLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(FromTextField)
                            .addComponent(TopicTextField)))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 494, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(FromTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(FromLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TopicTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TopicLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }
    
    private javax.swing.JLabel FromLabel;
    private javax.swing.JTextField FromTextField;
    private javax.swing.JTextArea MessageTextArea;
    private javax.swing.JLabel TopicLabel;
    private javax.swing.JTextField TopicTextField;
    private javax.swing.JScrollPane jScrollPane1;             
}
